<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./OL_SDK/include-openlayers-local.js"></script>
    <script src="./libs/gaode.js"></script>
    <script src="https://lib.baomitu.com/jquery/2.2.4/jquery.js"></script>
</head>

<body>
    <div id="dir">
        <input type="checkbox" checked> Area
        <input type="checkbox" checked> Line
        <input type="checkbox" checked> Point
    </div>
    <div id="map">
    </div>
    <script>
        // setLayerStatus
        /* openlayer原生api +mapgis-api */
        var docLayer = new Zondy.Map.Doc("", "myTestMap", {

        })
        var map = new ol.Map({
            target: "map",
            layers: [gaode, docLayer],
            view: new ol.View({
                projection: 'EPSG:4326',
                center: [114.30, 30.50],
                zoom: 4
            })
        })
        $("#dir input").change(function (evt) {
            var checked = evt.target.checked;
            console.log(checked,'checked')
            /* 获取图层的下标 */
            console.log(this,'this')
            console.log($(this),'$(this)')
            var index = $(this).index();
            console.log(index,'index')// 2 'index'
            docLayer.setLayerStatus([index], checked ? 'include' : 'exclude')
        })
    </script>
</body>

</html>